<form class="layui-form">
  <div class="layui-form-item">
    <label class="layui-form-label">用户名</label>
    <div class="layui-input-inline">
      <input type="text" name="user_name" lay-verify="required" placeholder="请输入用户名" id="name" value="{$user_info.user_name}"class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">真实姓名</label>
    <div class="layui-input-inline">
      <input type="text" name="real_name" lay-verify="required" placeholder="用户姓名" autocomplete="off" value="{$user_info.real_name}" id="name" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">登录密码</label>
    <div class="layui-input-inline">
      <input type="password" name="password" placeholder="请输入密码" value='' id="pwd" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">归属店铺</label>
	<div class="layui-input-inline">
      <select name="depart_id">
        <option value="">请选择</option>
        <volist name="list" id="vo">
        <option value="{$vo.depart_id}" <if condition="$vo['depart_id'] eq $user_info['depart_id']">selected</if>>{$vo.depart_name}</option>
        </volist>
      </select>
    </div>
  </div>
  <input type="hidden" value="{$user_info.id}" name="id">
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="user">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>
<script>
layui.use('form', function(){
	var form = layui.form(),
   		 $ = layui.jquery
	  //监听提交
	  form.on('submit(user)', function(data){
	    var userInfo = data.field;
		var url = "{:U('User/editUser')}";
		$.post(url,userInfo,function(data){
			if(data.status == 'error'){
				  layer.msg(data.msg,{icon: 5});//失败的表情
				  return;
			  }else if(data.status == 'success'){
				  layer.msg(data.msg, {
					  icon: 6,//成功的表情
					  time: 2000 //2秒关闭（如果不配置，默认是3秒）
					}, function(){
					   location.reload();
					}); 
			  }
		})
		
	    return false;//阻止表单跳转
	  });
	  form.render(); 
	});
</script>